﻿Imports System.Net
Imports System.Net.Dns
Public Class MainMenu
   
    Public Function GetExternalIP() As String
        Dim IP_URL As String = "http://checkip.dyndns.org"
        Dim strHTML, strIP As String
        Try
            Dim objWebReq As System.Net.WebRequest = System.Net.WebRequest.Create(IP_URL)
            Dim objWebResp As System.Net.WebResponse = objWebReq.GetResponse()
            Dim strmResp As System.IO.Stream = objWebResp.GetResponseStream()
            Dim srResp As System.IO.StreamReader = New System.IO.StreamReader(strmResp, System.Text.Encoding.UTF8)
            strHTML = srResp.ReadToEnd()
            Dim regexIP As System.Text.RegularExpressions.Regex
            regexIP = New System.Text.RegularExpressions.Regex("\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b")
            strIP = regexIP.Match(strHTML).Value
            Return strIP
        Catch ex As Exception
            MessageBox.Show("Can't retrieve external IP: " & ex.Message)
            Return Nothing
        End Try
    End Function

    Private Sub ICTHelpDeskToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Dim url As String = "http://ict.hasla.org.uk"
        Process.Start(url)
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Lbl_NetBios.Text = Environment.MachineName


        If (Environment.Is64BitOperatingSystem) Then
            lbl3264OS.Text = ("Your OS is 64 bits...  =]")
        Else
            lbl3264OS.Text = ("Your OS is 32 bits...Sorry about that.")
        End If

        Dim osInfo As System.OperatingSystem = System.Environment.OSVersion
        Timer1.Start()
        ToolStripStatusLabel2.Text = My.User.Name
        ExternalIP.Text = GetExternalIP()
        'SysUptme.Text = getUptime()

        'Label1.Text = osInfo.ToString


    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        ToolStripStatusLabel1.Text = My.Computer.Clock.LocalTime & " -"
        SysUptme.Text = getUptime()


    End Sub


    Private Sub AppVersionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AppVersionToolStripMenuItem.Click
        PasswordCheck.Hide()
        PasswordCheck.Show()

    End Sub

    Private Sub SpeedCheckToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Dim url As String = "http://speedof.me"
        Process.Start(url)
    End Sub

    Private Sub ToolsToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ToolsToolStripMenuItem1.Click
        NetTools.Hide()
        NetTools.Show()
    End Sub

    Private Sub ToolStripMenuItem3_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem3.Click
        LocalSystem.Hide()
        LocalSystem.Show()
    End Sub

    Private Sub CMDAdminToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles CMDAdminToolStripMenuItem.Click
        Dim process As System.Diagnostics.Process = Nothing
        Dim processStartInfo As System.Diagnostics.ProcessStartInfo

        processStartInfo = New System.Diagnostics.ProcessStartInfo()

        processStartInfo.FileName = "cmd.exe"

        If System.Environment.OSVersion.Version.Major >= 6 Then ' Windows Vista or higher
            processStartInfo.Verb = "runas"
        Else
            ' No need to prompt to run as admin
        End If

        processStartInfo.Arguments = ""
        processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
        processStartInfo.UseShellExecute = True

        Try
            process = System.Diagnostics.Process.Start(processStartInfo)
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally

            If Not (process Is Nothing) Then
                process.Dispose()
            End If

        End Try
    End Sub

    Private Sub GPReusltToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles GPReusltToolStripMenuItem.Click
        Dim Command As String
        Command = "gpresult /r"
        Shell("cmd /k" & Command, 1, True)
    End Sub

    Private Sub SETToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SETToolStripMenuItem.Click
        Dim Command As String
        Command = "set"
        Shell("cmd /k" & Command, 1, True)
    End Sub

    Private Sub TaskManagerToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles TaskManagerToolStripMenuItem.Click
        Dim osInfo As System.OperatingSystem = System.Environment.OSVersion
        If osInfo.Version.Major <= 5 Then
            'XP or Lower
            Process.Start("taskman")
        Else
            'Vista / 2008 Server
            Process.Start("taskmgr")
        End If
        'Dim Command As String
        'Command = "taskmgr"
        'Shell("cmd /k" & Command, 1, True)
    End Sub

    Private Sub ResourceManagerToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles ResourceManagerToolStripMenuItem.Click
        Dim osInfo As System.OperatingSystem = System.Environment.OSVersion
        If osInfo.Version.Major <= 5 Then
            'XP or Lower
            MsgBox("Does not exist in OS below W7, Have a nice day :)")
        Else
            'Vista / 2008 Server
            'MsgBox("CREAMFILDS!!!!")
            Process.Start("resmon")
        End If
        'Dim Command As String
        'Command = "taskmgr"
        'Shell("cmd /k" & Command, 1, True)
    End Sub

    Private Sub IPConfigallToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles IPConfigallToolStripMenuItem.Click
        Dim Command As String
        Command = "ipconfig /all"
        Shell("cmd /k" & Command, 1, True)
    End Sub

    Private Sub AbsenceRequestsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AbsenceRequestsToolStripMenuItem.Click
        Process.Start("http://10.22.80.18/absence")
    End Sub

    Private Sub FrogUsersToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Process.Start("https://frog.thestleonardsacademy.org")
    End Sub

    Private Sub FrogAdminToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Process.Start("https://frog.thestleonardsacademy.org/login.phtml")
    End Sub

    Private Sub SchoolBookingcomToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SchoolBookingcomToolStripMenuItem.Click
        Process.Start("https://secure.schoolbooking.com/external.php?site=stleonards")
    End Sub

    Private Sub SettingsPWPToolStripMenuItem_Click(sender As Object, e As EventArgs)
        PasswordCheck.Hide()
        PasswordCheck.Show()

    End Sub

    Private Sub SIMSFMSToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SIMSFMSToolStripMenuItem.Click
        SIMSFMS.Hide()
        SIMSFMS.Show()

    End Sub

    Private Sub TS412ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TS412ToolStripMenuItem.Click
        Process.Start("explorer.exe", "\\ts412")
    End Sub

    Private Sub ExternalIP_Click(sender As Object, e As EventArgs) Handles ExternalIP.Click
        Process.Start("http://www.infobyip.com/")
    End Sub

    Private Sub IPToolsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles IPToolsToolStripMenuItem.Click
        IPTools.Hide()
        IPTools.Show()

    End Sub

    Private Sub NETWORKDRIVESToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NETWORKDRIVESToolStripMenuItem.Click
        NetworkDrives.Hide()
        NetworkDrives.Show()

    End Sub

    Private Sub Vault101ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles Vault101ToolStripMenuItem.Click
        Process.Start("explorer.exe", "\\Vault101")
    End Sub

    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Lbl_NetBios.Click

    End Sub
End Class
